package com.itlong.cloud.operate.resource;

import com.itlong.cloud.POJO.DTO.operate.OperateShareProfitRuleDTO;
import com.itlong.cloud.POJO.VO.operate.OperateShareProfitRuleGetVO;
import com.itlong.cloud.operate.service.IOperateShareProfitRuleService;
import com.itlong.cloud.paymenthub.IOperateShareProfitRuleServiceClient;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <desc>
 *      分润规则信息管理接口暴露实现类
 * </desc>
 *
 * @createDate 2019/05/20
 */
@RestController
public class OperateShareProfitRuleServiceResource implements IOperateShareProfitRuleServiceClient {

    @Autowired
    private IOperateShareProfitRuleService iOperateShareProfitRuleService;

    /**
     * <desc>
     *      分页获取分润规则信息
     * </desc>
     *
     * @param operateShareProfitRuleDTO 分润规则信息DTO
     * @return 分润规则信息列表
     * @author wangzhi
     * @createDate 2019/05/20
     */
    @Override
    @PostMapping("/operate/shareProfitRule/getPage")
    public Page<OperateShareProfitRuleGetVO> getPage(@RequestBody OperateShareProfitRuleDTO operateShareProfitRuleDTO) throws Exception {
        return iOperateShareProfitRuleService.getPage(operateShareProfitRuleDTO);
    }

    /**
     * <desc>
     *      添加分润规则信息
     * </desc>
     *
     * @param operateShareProfitRuleDTO 分润规则信息DTO
     * @return 受影响行数
     * @author wangzhi
     * @createDate 2019/05/20
     */
    @Override
    @PostMapping("/operate/shareProfitRule/save")
    public Integer save(@RequestBody OperateShareProfitRuleDTO operateShareProfitRuleDTO) throws Exception {
        return iOperateShareProfitRuleService.save(operateShareProfitRuleDTO);
    }

    /**
     * <desc>
     *      查询单个分润规则
     * </desc>
     *
     * @param operateShareProfitRuleDTO 分润规则信息DTO
     * @return 分润规则
     * @author wangzhi
     * @createDate 2019/05/20
     */
    @Override
    @PostMapping("/operate/shareProfitRule/getOne")
    public OperateShareProfitRuleGetVO getOne(@RequestBody OperateShareProfitRuleDTO operateShareProfitRuleDTO) throws Exception {
        return iOperateShareProfitRuleService.getOne(operateShareProfitRuleDTO);
    }

    /**
     * <desc>
     *      修改分润规则信息
     * </desc>
     *
     * @param operateShareProfitRuleDTO 分润规则信息DTO
     * @return 受影响行数
     * @author wangzhi
     * @createDate 2019/05/20
     */
    @Override
    @PostMapping("/operate/shareProfitRule/update")
    public Integer update(@RequestBody OperateShareProfitRuleDTO operateShareProfitRuleDTO) throws Exception {
        return iOperateShareProfitRuleService.update(operateShareProfitRuleDTO);
    }

    /**
     * <desc>
     *      删除分润规则信息，可批量
     * </desc>
     *
     * @param ruleIds 分润规则信息id，多个英文逗号相连
     * @return 受影响行数
     * @author wangzhi
     * @createDate 2019/05/20
     */
    @Override
    @PostMapping("/operate/shareProfitRule/delete")
    public Integer delete(@RequestParam("ruleIds") String ruleIds) throws Exception {
        return iOperateShareProfitRuleService.delete(ruleIds);
    }

    /**
     * <desc>
     *      校验分润规则是否闲置
     * </desc>
     *
     * @param ruleIds 分润规则信息id，多个英文逗号相连
     * @return true-是，false-否
     * @author wangzhi
     * @createDate 2019/05/20
     */
    @Override
    @PostMapping("/operate/shareProfitRule/checkRuleIdle")
    public boolean checkRuleIdle(@RequestParam("ruleIds") String ruleIds) throws Exception {
        return iOperateShareProfitRuleService.checkRuleIdle(ruleIds);
    }
}
